package token

// IsSpace test if the given rune is spaces.
func IsSpace(ch rune) bool {
	return ch == ' '
}

// IsNumber test if the given rune is number.
func IsNumber(ch rune) bool {
	return '0' <= ch && ch <= '9'
}

// IsAlphaBet test if the given rune is alphabet.
func IsAlphaBet(ch rune) bool {
	return ('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z')
}

// IsWord test if the given rune is alphabet or number or underline.
func IsWord(ch rune) bool {
	return IsAlphaBet(ch) || IsNumber(ch) || ch == '_'
}

// IsCharOf generate a function that tests if the given rune is the target character.
func IsCharOf(target rune) func(ch rune) bool {
	return func(ch rune) bool {
		return ch == target
	}
}

// IsOppositeOf return an opposite function.
func IsOppositeOf(cond func(ch rune) bool) func(ch rune) bool {
	return func(ch rune) bool {
		return !cond(ch)
	}
}
